package com.etoak.util;

/**
 * Description :
 * Author : 91658
 * Date : 2018/6/7 10:41
 **/
public class WebResponse<T> {

    private Integer status;
    private String message;
    private T data;

    public WebResponse() {
    }

    public WebResponse(Integer status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public WebResponse(String message, T data) {
        this.message = message;
        this.data = data;
    }

    public static<T> WebResponse<T> createBySuccess(String message, T data) {
        return new WebResponse<T>(ResponseCode.SUCCESS.getCode(), message, data);
    }

    public static<T> WebResponse<T> createByFail(String message, T data) {
        return new WebResponse<T>(ResponseCode.FAIL.getCode(), message, data);
    }

    public static<T> WebResponse<T> createByError(String message, T data) {
        return new WebResponse<T>(ResponseCode.ERROR.getCode(), message, data);
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
